<!--{template header}-->
 {eval $hidefooter=true;}

{eval $authoruid=$question['authorid'];}
<script>
var _qtitle="{$question['title']}";

{if 0!=$question['shangjin']}
_qtitle=_qtitle+"-【现金悬赏{$question['shangjin']}元】";
{/if}
	{eval $miaosu=strip_tags($question['description']);}
	 {eval $miaosu=cutstr(str_replace('&nbsp;','',$miaosu),200,'...');}
	 {eval $miaosu=str_replace('"', '', $miaosu);}
	 {eval $miaosu=str_replace('“', '', $miaosu);}
	 {eval $miaosu=str_replace('”', '', $miaosu);}
	 var _qcontent="{eval echo trim($miaosu);}";
//var imgurl="{$question['author_avartar']}";
var imgurl="{$question['author_avartar']}";

</script>

<style>
.publish_time{
    margin-top: 10px;
    font-size: 14px;
    color: #8590A6;
}
.operationlist a{
color: #8590A6;
margin-right:3px;
}
.yuyinplay{
	background:#41c074;
    width:180px;
    height:30px;
line-height:30px;
    border-radius:50px;
    text-align:center;
color:#fff;
  position:relative;

}
.ui-icon-voice{
	color:#fff;
    font-size:22px;
    position:relative;
    float:left;
     margin-left:10px;
     top:-8px;
}
.u-voice{
	color:#fff;

   font-size:13px;
    float:right;
     margin-right:10px;

}
.wtip{
	font-size:13px;
}
</style>

<section class="ui-container ">
<div class="question_wapinsertcode" id="question_wapinsertcode_1"></div>
                  <!-- 问题标签 -->
                  {template solve_question_tag}
    <article class="article">
<div class="question_wapinsertcode" id="question_wapinsertcode_2"></div>
           <!-- 问题标题 -->
                  {template solve_question_title}
    
         <!-- 问题用户信息和发布时间 -->
                  {template solve_question_userinfoandpubtime}
                  <div class="question_wapinsertcode" id="question_wapinsertcode_3"></div>
                     <!-- 问题描述-->
                  {template solve_question_description}
<div class="question_wapinsertcode" id="question_wapinsertcode_4"></div>
            <script type="text/javascript">
            {if $openId==null || PHP_OS=='WINNT'}
            var canyuyin=0;
            {else}
            var canyuyin=1;
            {/if}
            </script>
        	   <!-- cdn节点 问题操作按钮 -->
                        <div class="cdn_question_button"></div>
                        
            
                   <script type="text/javascript">
getquestioncaozuo(4,{$question['id']});
</script>
   </article>
   
   
   		     <!-- 问题关闭提示-->
                  {template solve_question_closetext}
   
      <div class="question_wapinsertcode" id="question_wapinsertcode_5"></div>
    <!--提交回答-->
           {template solve_question_postanswer}
   <div class="question_wapinsertcode" id="question_wapinsertcode_6"></div>
    <section class="answerlist">
        <!--问题回答总数提示-->
           {template solve_question_answerstext}
  <div class="question_wapinsertcode" id="question_wapinsertcode_7"></div>
    <style>    
.answer-items .answer-item{
position:relative;
}
    </style>
        <div class="answers">
            <div class="answer-items">
            <div class="question_wapinsertcode" id="question_wapinsertcode_8"></div>
               <!--最佳回答-->
           {template solve_question_bestanswer}
           <div class="question_wapinsertcode" id="question_wapinsertcode_9"></div>
                  <!--其它回答-->
           {template solve_question_otheranswerlist}  
           <div class="question_wapinsertcode" id="question_wapinsertcode_10"></div>                
            </div>
        </div>
<div class="question_wapinsertcode" id="question_wapinsertcode_11"></div>
       <!--邀请列表-->
           {template solve_question_invatelist}   
           <div class="question_wapinsertcode" id="question_wapinsertcode_12"></div>
    </section>
  <div class="question_wapinsertcode" id="question_wapinsertcode_13"></div>
  <!-- 相关问题 -->
        {template solve_question_qlist} 
<div class="question_wapinsertcode" id="question_wapinsertcode_14"></div>
</section>


<!-- 举报弹出框 -->
   {template solve_question_jubao} 


    <section>
<div class="question_wapinsertcode" id="question_wapinsertcode_15"></div>
<!-- 回答 -->
{template solve_question_yuyinhuida}
</section>


<script>
$(function(){
	$(".article img").css("height","auto")
})
//投诉
function openinform(qid ,qtitle,aid) {
	  $("#myqid").val(qid);
	  $("#myqtitle").val(qtitle);
	  $("#myaid").val(aid);
	 $('#dialog_inform').show();

}
function hidemodel(){
	$('#dialog_inform').hide();
}
//questioncaozuo
var current_aid=0;
var qid={$qid};




function viewanswer(paymoney,_qid,_answerid){
  
	{if $lastviewnum}
	   var dia=$.dialog({
	        title:'<center>温馨提示</center>',
	        select:0,
	        content:'<center><p style="color:red;margin-top:5px;">此回答需要付费'+paymoney+'元</p><p style="color:blue;margin-top:5px;">您当前有{$lastviewnum}张偷看卡</p></center>',
	        button:["使用偷看卡","取消"]
	    });
	   {else}
	   {if $this->user ['viewanswertimes']>0}
	   {eval $viewanswertimes= $this->user ['viewanswertimes'];}
	   var dia=$.dialog({
	        title:'<center>温馨提示</center>',
	        select:0,
	        content:'<center><p style="color:red;margin-top:5px;">此回答需要付费'+paymoney+'元</p><p style="color:blue;margin-top:5px;">搜题包剩余{$viewanswertimes}次</p></center>',
	        button:["使用搜题包","取消"]
	    });
	   {else}
	   var dia=$.dialog({
	        title:'<center>温馨提示</center>',
	        select:0,
	        content:'<center><p style="color:red;margin-top:5px;">此回答需要付费'+paymoney+'元</p></center>',
	        button:["确认支付","取消"]
	    });
	   {/if}
	 
	   {/if}
		   var postviewanswer=false;
	    dia.on("dialog:action",function(e){
	    	if(e.index==1){
	    		return false;
	    	}
	    	if(postviewanswer){
		  	  	return false;
		  	}
			postviewanswer=true;
	    	 $.ajax({
		 	        //提交数据的类型 POST GET
		 	        type:"POST",
		 	        //提交的网址
		 	        url:"{url answerpay/ajaxpostanswerreward}",
		 	        //提交的数据
		 	        data:{answerid:_answerid},
		 	        //返回数据的格式
		 	        datatype: "text",//"xml", "html", "script", "json", "jsonp", "text".

		 	        //成功返回之后调用的函数
		 	        success:function(data){

		 	        	data=$.trim(data);
		 	        	console.log(data)
		 	        	if(data==-2){
			 	        	window.location.href="{SITE_URL}"+g_prefix+"answerpay/poppay/"+_qid+"/"+_answerid+"{$setting['seo_suffix']}";
		 	        		//alert('游客先登录!');
		 	        	}
		 	        	if(data==-1){
		 	        		alert('此问题不需要付费!');
		 	        	}
		 	        	if(data==2){
		 	        		alert('此问题您已经付费过了!');
		 	        	}
		 	        	if(data==0){
		 	        		window.location.href="{SITE_URL}"+g_prefix+"answerpay/poppay/"+_qid+"/"+_answerid+"{$setting['seo_suffix']}";
		 	        		//alert('账户余额不足，先充值!');
		 	        	}
		 	        	if(data==1){
		 	        		window.location.reload();
		 	        	}
		 	        }   ,

		 	        //调用出错执行的函数
		 	        error: function(){
		 	            //请求出错处理
		 	        	postviewanswer=false;
		 	        }
		 	    });
	       // console.log(e.index)
	    });
	    dia.on("dialog:hide",function(e){
	       // console.log("dialog hide")
	    });




}
var mobile_localyuyin=0;
var targetplay=null;
$(".yuyinplay").click(function(){
	targetplay=$(this);
	var _serverid=targetplay.attr("id");
	   if(_serverid == '') {
			 el2=$.tips({
		         content:'语音文件丢失',
		         stayTime:2000,
		         type:"info"
		     });
           return;
       }
	   $(".wtip").html("免费偷听");
	   targetplay.find(".wtip").html("播放中..");
	   if(mobile_localyuyin==1){
		   var myAudio =targetplay.find("#voiceaudio")[0];

		   if(myAudio.paused){
			   targetplay.find(".wtip").html("播放中..");
	           myAudio.play();
	       }else{
	    	   targetplay.find(".wtip").html("暂停..");
	           myAudio.pause();
	       }
		   function endfun(){ targetplay.find(".wtip").html("播放结束");}
		   var   is_playFinish = setInterval(function(){
	           if( myAudio.ended){

	        	   endfun();
		                    window.clearInterval(is_playFinish);
	           }
	   }, 10);
	   }else{
		    wx.downloadVoice({
	           serverId: _serverid,
	           isShowProgressTips: 1,
	           success: function (res) {
	              var _localId = res.localId;

	               wx.playVoice({
	                   localId: _localId
	               });
	           }
	       });
	   }


})

</script>
<script>
$(".answerlist .ans-content").each(function(){
	if($(this).height()>100){
		$(this).parent().find(".readmore").show();
	}else{
		$(this).parent().find(".readmore").hide();
	}
});
$(".readmore").click(function(){
	if($(this).html()=="查看更多"){
		$(this).parent().find(".answerlist .ans-content").css("max-height","fit-content").css("overflow","visible");
		$(this).html("收起");
	}else{
		$(this).parent().find(".answerlist .ans-content").css("max-height","100px").css("overflow","hidden");
		$(this).html("查看更多");
	}
	
});

$(".voiceanswer").click(function(){
	  $('.ui-actionsheet').addClass('hide');
	  var luyin=$(".luyin").dialog("show");
	  luyin.on("dialog:action",function(e){
	        console.log(e.index);

	    });
});
$(".textanswer").click(function(){
	  $('.ui-actionsheet').addClass('hide');
	var dia2=$(".answerbox").show();

    $(".dialogcomment .ui-icon-close").click(function(){
    	$(".answerbox").hide();
    })
})

	 $(".btn-agree").click(function(){
                        var supportobj = $(this);
                                var answerid = $(this).attr("id");
                                var el='';
                                $.ajax({
                                type: "GET",
                                        url:"{SITE_URL}index.php?answer/ajaxhassupport/" + answerid,
                                        cache: false,
                                        beforeSend:function(){
                                    	    el=$.loading({
                                    	        content:'加载中...',
                                    	    })
                                       },
                                        success: function(hassupport){
                                        	 el.loading("hide");
                                        if (hassupport != '1'){






                                                $.ajax({
                                                type: "GET",
                                                        cache:false,
                                                        url: "{SITE_URL}index.php?answer/ajaxaddsupport/" + answerid,
                                                        success: function(comments) {

                                                        supportobj.find(".agree-num").html(comments);
                                                   	 el2=$.tips({
                                          	            content:'感谢支持',
                                          	            stayTime:1000,
                                          	            type:"success"
                                          	        });
                                                        }
                                                });
                                        }else{
                                        	 el2=$.tips({
                                 	            content:'您已赞过',
                                 	            stayTime:1000,
                                 	            type:"info"
                                 	        });
                                        }
                                        },
                                        //调用执行后调用的函数
                                        complete: function(XMLHttpRequest, textStatus){
                                     	    el.loading("hide");
                                        },
                                });
                        });
                        //添加评论
                        function addcomment(answerid) {

                        var content = $("#comment_" + answerid + " input[name='content']").val();

                        var replyauthor = $("#comment_" + answerid + " input[name='replyauthor']").val();

                        if (g_uid == 0){

                            window.location.href="{SITE_URL}index.php?user/login";
                           return false;
                        }
                        if (bytes($.trim(content)) < 5){

                        el2=$.tips({
            	            content:'评论内容不能少于5字',
            	            stayTime:1000,
            	            type:"info"
            	        });
                                return false;
                        }

                        $.ajax({
                        type: "POST",
                                url: "{SITE_URL}index.php?answer/addcomment",
                                data: "content=" + content + "&answerid=" + answerid+"&replyauthor="+replyauthor,
                                success: function(status) {
                                if (status == '1') {
                                $("#comment_" + answerid + " input[name='content']").val("");
                                        load_comment(answerid);
                                        return false;
                                }else{
                                	if(status == '-2'){

                                		 el2=$.tips({
                             	            content:"问题已经关闭，无法评论",
                             	            stayTime:1000,
                             	            type:"info"
                             	        });
                                	}
                                }
                                }
                        });
                        return false;
                        }

                        //删除评论
                        function deletecomment(commentid, answerid) {
                        if (!confirm("确认删除该评论?")) {
                        return false;
                        }
                        $.ajax({
                        type: "POST",
                                url: "{SITE_URL}index.php?answer/deletecomment",
                                data: "commentid=" + commentid + "&answerid=" + answerid,
                                success: function(status) {
                                if (status == '1') {
                                load_comment(answerid);
                                }
                                }
                        });
                        }
                        function load_comment(answerid){
                        $.ajax({
                        type: "GET",
                                cache:false,
                                url: "{SITE_URL}index.php?answer/ajaxviewcomment/" + answerid,
                                success: function(comments) {
                                $("#comment_" + answerid + " .comments-list").html(comments);
                                }
                        });
                        }
                        function show_comment(answerid) {

                            if ($("#comment_" + answerid).css("display") === "none") {
                            load_comment(answerid);
                                    $("#comment_" + answerid).css({"display":"block"});
                            } else {
                            $("#comment_" + answerid).css({"display":"none"});
                            }
                            }
                        function replycomment(commentauthorid,answerid){

                            var comment_author = $("#comment_author_"+commentauthorid).attr("title");

                            $("#comment_"+answerid+" .comment-input").focus();
                            $("#comment_"+answerid+" .comment-input").val("回复 "+comment_author+" :");
                            $("#comment_" + answerid + " input[name='replyauthor']").val(commentauthorid);
                        }


</script>

<!--{template footer}-->